var { getAllLocalIp } = require('../qrcode/ip-util')
var ips = getAllLocalIp()
var fs = require('fs')
var path = require('path')
var config = require('../config')
var outputStr = `/* eslint-disable */\nvar CURRENT_IPS = [${ips.map((ip) => `'${ip}'`).join(', ')}]\nvar PORT = ${config.dev.port || 3000};`
// fs.writeFileSync(path.resolve(__dirname, 'config.js'), outputStr)
var url = `http://localhost:7777/qrcode`
var opn = require('opn')
var serve = require('serve')
fs.writeFile(path.resolve(__dirname, 'config.js'), outputStr, function (err, logData) {
  if (err) throw err
  console.log(path.resolve(__dirname, '../'))
  serve(path.resolve(__dirname, '../'), {
    port: '7777'
  })
  opn(url)
})
// console.log('init end')
// setTimeout(() => {
//   opn(url)
// }, 1000)
